import Vue from "vue";
import Vuex from 'vuex'

import mutations from "./mutations";
import actions from "./actions";
import getters from "./getters";
import moduleA from "./modules/moduleA";
//1.安装插件
Vue.use(Vuex)

//2.创建对象
const state = {
    // states:存储了项目的公共数据/状态
    counter: 1000,
    students: [
        { id: 110, name: 'jackson', age: 29 },
        { id: 220, name: 'wang', age: 13 },
        { id: 330, name: 'ccj', age: 21 },
    ],
    info: {
        name: 'kobe',
        age: 40,
        height: 188
    }
}
const store = new Vuex.Store({
        state: state,
        actions: actions,
        mutations: mutations,
        getters: getters,
        //允许将单一的store拆分为多个store，且保存在单一状态树中
        modules: {
            a: moduleA
        }
    })
    //3.导出store对象
export default store